<!DOCTYPE HTML>
<%@page import="java.util.Iterator"%>
<%@page import="shop.factory.DAOFactory"%>
<%@page import="java.util.List"%>
<%@page import="shop.vo.AddressBean"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<meta charset="UTF-8" />
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/address.css" />
<script src="../js/jquery-1.10.2.min.js" type="text/javascript"
	charset="utf-8"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<title>修改地址簿</title>
</head>
<%
	int id = (int) session.getAttribute("address");
	String str = (String)session.getAttribute("user");
	List<AddressBean> list = DAOFactory.getIAddressDAOInstance().findAdd(id);
	Iterator<AddressBean> it = list.iterator();
%>
<body>
	<nav class="navbar navbar-default" role="navigation">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target="#bs-example-navbar-collapse-1">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
		</div>
		<div class="collapse navbar-collapse"
			id="bs-example-navbar-collapse-1">
			<ul class="nav navbar-nav">
				<li class="active"><a href="../index.jsp">首页</a></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyOrder"> <img src="../images/order.png" /> 我的订单
				</a></li>
				<li></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyCart"> <img src="../images/car.png" /> 我的购物车
				</a></li>
				<li><a href="<%=request.getContextPath() %>/FavoriteServlet?action=MyFav"> <img src="../images/favorite.png" /> 我的收藏
				</a></li>
			</ul>

			<ul class="nav navbar-nav navbar-right">
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=xinxi"><span id="huanying">欢迎光临，游客</span></a></li>
				<li><a href="../Login/login.jsp">登陆</a></li>
				<li><a href="../Login/regist.jsp">注册</a></li>
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=logout" class="active" onclick="return confirm('确认退出?')">退出</a></li>
			</ul>
		</div>
	</nav>
	<div class="container">
		<h2>修改地址簿</h2>
		<div class="page-header"></div>
	</div>

	<div class="container" style="height: 396px;">
		<table class="table">
			<thead>
				<tr>
					<th>姓名</th>
					<th>收货地址</th>
					<th>邮政编码</th>
					<th>手机号码</th>
				</tr>
			</thead>
			<tbody>
				<%
					if (it.hasNext()) {
						AddressBean addr = it.next();
				%>
				<form action="<%=request.getContextPath() %>/AddressServlet?id=<%=addr.getAddr_id() %>" method="post" onsubmit="return checkAll()">
					<tr>
						<td><input type="text" name="username" id="username" value="<%=str %>" readonly="readonly"/></td>
						<td><textarea name="address" id="address" rows="3" cols="25"><%=addr.getAddr_address() %></textarea></td>
						<td><input type="text" name="zip" id="zip" value="<%=addr.getAddr_zip() %>" /></td>
						<td><input type="text" name="mobile" id="mobile" value="<%=addr.getAddr_mobile() %>" /></td>
					</tr>
					<input type="submit" value="确认修改" class="btn btn-danger" />
					<input type="hidden" name="action" value="change">
				</form>
				<%
					}
				%>
				
			</tbody>
		</table>
	</div>

	<div class="container-fluid foot-bg">
		<p>Power by Liang&Luo @版本号V0.0.01</p>
	</div>
	<script src="js/changeaddress.js" type="text/javascript" charset="utf-8"></script>
</body>
<script type="text/javascript">
<%
	String str0 = (String)session.getAttribute("user");
	if (session.getAttribute("user") != null) {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，<%=str0%>";
<%
	} else {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，游客";
<%
	}
%>
</script>
</html>